package com.gitee.wsl.coroutines.job.listener

import com.gitee.wsl.coroutines.job.IJobExecutionContext
import com.gitee.wsl.coroutines.job.exception.JobExecutionException
import com.gitee.wsl.coroutines.job.trigger.ITrigger
import com.gitee.wsl.coroutines.job.trigger.ITriggerListener


interface IJobListener {
    /**
     *
     *
     * Get the name of the `JobListener`.
     *
     */
    val name: String

    /**
     *
     *
     * Called by the `[IScheduler]` when a
     * `[com.helger.quartz.IJobDetail]` is about to be executed
     * (an associated `[ITrigger]` has occurred).
     *
     *
     *
     * This method will not be invoked if the execution of the Job was vetoed by a
     * `[ITriggerListener]`.
     *
     *
     * @param context
     * @see .jobExecutionVetoed
     */
    fun jobToBeExecuted(context: IJobExecutionContext) {}

    /**
     *
     *
     * Called by the `[IScheduler]` when a
     * `[com.helger.quartz.IJobDetail]` was about to be executed
     * (an associated `[ITrigger]` has occurred), but a
     * `[ITriggerListener]` vetoed it's execution.
     *
     *
     * @param context
     * @see .jobToBeExecuted
     */
    fun jobExecutionVetoed(context: IJobExecutionContext) {}

    /**
     *
     *
     * Called by the `[IScheduler]` after a
     * `[com.helger.quartz.IJobDetail]` has been executed, and be
     * for the associated `Trigger`'s `triggered(xx)` method
     * has been called.
     *
     *
     * @param context
     * @param jobException
     */
    fun jobWasExecuted(context: IJobExecutionContext, jobException: JobExecutionException?) {}
}
